Loading TOC...

MarkLogic 10 Product Documentation
PUT /v1/config/namespaces/{prefix}

Summary

[DEPRECATED: Use PUT /manage/v2/servers/{id|name}/properties instead.]

Create or modify a namespace binding.

URL Parameters
format? You can use this parameter as a fallback to the request Content-type header. The Content-type header takes precedence over format in most cases; for details, see Controlling Input and Output Content Type in the REST Application Developer's Guide. Accepted values: json or xml.
Request Headers
Content-Type? The MIME type of the data in the request body, either application/xml or application/json.

Response

MarkLogic Server responds with status 201 (Created) if a new prefix binding is created as a result of this request. MarkLogic Server responds with status 204 (Updated) if an existing prefix binding is updated as a result of this request.

Required Privileges

This operation requires the rest-admin role, or the following privileges:

http://marklogic.com/xdmp/privileges/rest-admin

http://marklogic.com/xdmp/privileges/rest-writer

http://marklogic.com/xdmp/privileges/rest-reader

Usage Notes

For details, see Using Namespace Bindings in the REST Application Developer's Guide.

The request body must have the following format when sending XML:

  <namespace xmlns="http://marklogic.com/rest-api">
    <prefix>the-prefix</prefix>
    <uri>the-uri</uri>
  </namespace>
    

The request body must have the following format when sending JSON:

  { "prefix" : "the-prefix", "uri" : "the-uri" }
    

Example

$ cat ns-xml
<namespace xmlns="http://marklogic.com/rest-api">
  <prefix>bill</prefix>
  <uri>http://marklogic.com/examples/shakespeare</uri>
<namespace>

$ curl --anyauth --user user:password -T './ns-xml' -i \
  -H "Content-type: application/xml" \
  http://localhost:8000/v1/config/namespaces/bill

==> Create or update a namespace binding between the prefix "bill" and the
    namespace URI http://marklogic.com/examples/shakespeare. MarkLogic
    Server returns the following headers:

Server: MarkLogic
Content-Type: text/plain; charset=UTF-8
Content-Length: 31
Connection: close

HTTP/1.1 100 Continue

HTTP/1.1 204 Updated
Server: MarkLogic
Content-Length: 0
Connection: close
  

Example

$ cat ns-json
{ "prefix" : "will", "uri" : "http://marklogic.com/examples/shakespeare" }

$ curl --anyauth --user user:password -T './ns-json' -i \
  -H "Content-type: application/json" \
  http://localhost:8000/v1/config/namespaces/will

==> Create or update a namespace binding between the prefix "will" and the
    namespace URI http://marklogic.com/examples/shakespeare. MarkLogic
    Server returns the following headers:

Server: MarkLogic
Content-Type: text/plain; charset=UTF-8
Content-Length: 31
Connection: close

HTTP/1.1 100 Continue

HTTP/1.1 204 Updated
Server: MarkLogic
Content-Length: 0
Connection: close
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.